<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="数据集" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入数据集名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工况" prop="conditionNumber">
        <el-input
          v-model="queryParams.conditionNumber"
          placeholder="请输入工况名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="轴承" prop="bearingNumber">
        <el-input
          v-model="queryParams.bearingNumber"
          placeholder="请输入轴承名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="Data" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column prop="pic" label="轴承图片测试" align="center">
        <template slot-scope="scope" align="left">
          <img :src="scope.row.pic"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit">
<!--            @click="handleUpdate(scope.row)"-->
<!--            v-hasPermi="['bearing:bearingModel:edit']"-->
          下载
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import {getPic} from "@/api/bearing/signal";

  export default {
    name: "Signal",
    data() {
      return {
        // 遮罩层
        loading: false,
        // 选中数组
        ids: [],
        Data: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 数据集表格数据
        datasetList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          name: null,
          datasetName: null,
          conditionName: null,
          bearingName: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {}
      }
    }
    ,
    /**
     * 数据发生改变
     */

    watch: {}
    ,

    /**
     * 创建完毕
     */

    created() {
      this.$nextTick(() => {
        //this.getdata()
      })
    },

    /**
     * 里面的方法只有被调用才会执行
     */

    methods: {
      // 查询所有元器件信息
      getList() {
        this.loading = true
        let data = new FormData();
        getPic(data)
          .then(res => {
            
            this.pic = res.rows[0]
            let s = 'data:image/jpg;base64,' + res.rows[0]
            let p1 = s.replace(/[\r\n]/g, '')
            let s1 = 'data:image/jpg;base64,' + res.rows[1]
            let p2 = s1.replace(/[\r\n]/g, '')
            let s2 = 'data:image/jpg;base64,' + res.rows[2]
            let p3 = s2.replace(/[\r\n]/g, '')
            this.Data = [{pic: p1}, {pic: p2},{pic:p3}]
            this.loading = false
          }).catch(() => {
          this.loading = false
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        //this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.bid)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
    }
  }
</script>

